﻿namespace ACCOUNTING
{
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Management;

    [StandardModule]
    internal sealed class GetMachineInfoModule
    {
        public static string GetCPUId()
        {
            string str = string.Empty;
            ManagementObjectCollection instances = new ManagementClass("Win32_Processor").GetInstances();
            foreach (ManagementObject obj2 in instances)
            {
                if (str == string.Empty)
                {
                    str = obj2.Properties["ProcessorId"].Value.ToString();
                }
            }
            return str;
        }

        public static string GetMACAddress()
        {
            ManagementObjectCollection instances = new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances();
            string str2 = string.Empty;
            foreach (ManagementObject obj2 in instances)
            {
                if ((str2 == string.Empty) && Conversions.ToBoolean(obj2["IPEnabled"]))
                {
                    str2 = obj2["MacAddress"].ToString();
                }
                obj2.Dispose();
            }
            return str2.Replace(":", "");
        }

        public static string GetVolumeSerial(string strDriveLetter)
        {
            if ((strDriveLetter == "") || (strDriveLetter == null))
            {
                strDriveLetter = "C";
            }
            ManagementObject obj2 = new ManagementObject("win32_logicaldisk.deviceid=\"" + strDriveLetter + ":\"");
            obj2.Get();
            return obj2["VolumeSerialNumber"].ToString();
        }
    }
}

